import Vue from "vue";

import Vuex from "vuex";

import Cart from "./Cart";
import Product from "./Product";
//引入插件
import timeTravel from "./plugins/timeTravel";
//引入vuex-persistedstate插件
import creatPersistedState from "vuex-persistedstate";

Vue.use(Vuex)

export default new Vuex.Store({
    //一共6个属性
    //1.状态
    state: {
        user:"lbw",
        num:555
    },
    //2.用于变更状态
    mutations: {},
    //3.用于异步操作
    actions: {},
    //4.数据预处理（相当于vue的计算属性）
    getters: {},
    //5.模块化
    modules: {
        Cart,
        Product
    },
    //6.插件
    plugins: [timeTravel,creatPersistedState({
    // 存储方式：localStorage、sessionStorage、cookies
        storage: window.localStorage,
        // 存储的 key 的key值
                key: "2204",
                paths:['num']
    })],
})